/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
function getChart(title, data_x, data_y) {
    return {
//        title: {
//            text: title,
//            x: 'center'
//        },
//        legend: {
//            data: ['流量', '降雨量'],
//            x: 'left'
//        },
//        toolbox: {
//            show: true,
//            feature: {
//                mark: {show: true},
//                dataView: {show: true, readOnly: false},
//                magicType: {show: true, type: ['line', 'bar']},
//                restore: {show: true},
//                saveAsImage: {show: true}
//            }
//        },
//        dataZoom: {
//            show: true,
//            realtime: true,
//            start: 0,
//            end: 100
//        },
        xAxis: [
            {
                type: 'category',
                boundaryGap: false,
                axisLine: {onZero: false},
                data: data_x,
                show: false
            }
        ],
        yAxis: [
            {
                name: title,
//                type: 'value',
//            max : 500,
                axisLine: {onZero: false},
                show: true
            }

        ],
        series: [
            {
                name: '流量',
                type: 'line',
                itemStyle: {normal: {areaStyle: {type: 'default'}}},
                data: data_y

            }

        ]
    }
}

function getChart2(title, data_x, data_y, type) {
    var num = 50;
    if (type && type == "PLT") {
        num = 25;
    }
    return {
        chart: {
            type: 'spline',
            zoomType: 'x',
            backgroundColor: 'rgba(0,0,0,0)',
            plotBorderColor: 'rgba(255,255,255,0)'
        },
        credits: {
            enabled: false
        },
        title: {
            text: null
        },
        xAxis: {
            lineColor: 'black',
            text: null,
//             categories: [50,100,150,200,250],
            labels: {
                formatter: function () {
                    console.log(this.value);
                    if (type && type == 'PLT') {
                        return this.value / 5;
                    } else {
                        return this.value;
                    }

                }
            },
//            startOnTick: 'yes',
//            endOnTick: 'yes',
//            minorTickInterval: 'auto', //设置是否出现纵向小标尺  
//            minorGridLineColor: '#E0E0E0',
            lineColor: '#197F07', //设置X轴颜色  
            tickWidth: 1, //设置X轴坐标点是否出现占位及其宽度  
//            tickPixelInterval: 10, //设置横坐标密度 
            tickInterval: num,
            tickPositioner: function () {
//                console.log(this.dataMax + ":" + this.dataMin);
//                if (type && type == 'PLT') {
//                    var positions = [50, 100, 150, 200, 250];
//                    return positions;
//                }

//                    tick = Math.floor(this.dataMin),
//                    increment = Math.ceil((this.dataMax - this.dataMin) / 6);
//
//                if (this.dataMax !== null && this.dataMin !== null) {
//                    for (tick; tick - increment <= this.dataMax; tick += increment) {
//                        positions.push(tick);
//                    }
//                }

            },
//            type: 'datetime',
//            labels: {
//                overflow: 'justify'
//            },
            showEmpty: false
        },
        yAxis: {
            title: {
                text: null
            },
//              tickPixelInterval:10, 
//            max: 300,
//            minRange: 100,
            lineColor: 'black',
            lineWidth: 1
        },
        legend: {
            lineColor: 'black',
            borderColor: 'red',
            layout: 'vertical',
            align: 'center',
            verticalAlign: 'top',
            floating: true,
            //backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF',
            borderWidth: 0
        },
        series: [{
                lineWidth: 1,
                color: 'black',
                name: title,
                data: data_y
            }
//        , {
//            name: 'Vik',
//            data: [0, 0, 0.6, 0.9, 0.8, 0.2, 0, 0, 0, 0.1, 0.6, 0.7, 0.8, 0.6, 0.2, 0, 0.1, 0.3, 0.3, 0, 0.1, 0, 0, 0, 0.2, 0.1, 0, 0.3, 0, 0.1, 0.2, 0.1, 0.3, 0.3, 0, 3.1, 3.1, 2.5, 1.5, 1.9, 2.1, 1, 2.3, 1.9, 1.2, 0.7, 1.3, 0.4, 0.3]
//        }
        ],
        navigation: {
            menuItemStyle: {
                fontSize: '10px'
            }
        }
    }
}
//散点图
function getChart3(title, data) {

    return {
        chart: {
            type: 'scatter',
//            zoomType: 'xy',
            backgroundColor: 'rgba(0,0,0,0)',
            plotBorderColor: 'rgba(255,255,255,0)'
        },
        credits: {
            enabled: false
        },
        title: {
            text: null
        },
//        subtitle:{
//            text: title
//        },

        xAxis: {
            title: {
                enabled: true,
                text: null
            },

            lineColor: 'black',
            text: title,
            labels: {

                enabled: true //设置刻度是否显示

            }
//            startOnTick: true,
//            endOnTick: true,
//            showLastLabel: true
        },
        yAxis: {
            title: {
                text: null
            },
            lineColor: 'black',
            lineWidth: 1
        },
        legend: {
            lineColor: 'black',
            borderColor: 'red',
            layout: 'vertical',
            align: 'center',
            verticalAlign: 'bottom',
            x: -5, //间隔x轴的间隔
            y: 0, //间隔Y轴的间隔
            floating: true,
            //backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF',
            borderWidth: 0
        },
        plotOptions: {
            scatter: {
                marker: {
                    radius: 1,
                    states: {
                        hover: {
                            enabled: true,
                            lineColor: 'rgb(100,100,100)'
                        }
                    }
                },
                states: {
                    hover: {
                        marker: {
                            enabled: false
                        }
                    }
                }

            }
        },
        series: [{
                name: title,
                color: 'rgba(0, 0, 0, 1)',
                data: data
            }]
    };

}


function zkChart(sd,data,day) {
    var value = parseFloat(sd);
    console.log(sd);
    console.log(data);
    return {
        chart: {
            type: 'line',
            zoomType: 'x',
            backgroundColor: 'rgba(0,0,0,0)',
            plotBorderColor: 'rgba(255,255,255,0)'
        },
        credits: {
            enabled: false
        },
        title: {
            text: null
        },
        xAxis: {
              title: {
                text: null
            },
            lineColor: 'black',
            text: null,
            min: 0,
            max: day.length,
            categories: day,

//            type: 'datetime',
//            labels: {
//                overflow: 'justify'
//            },
            showEmpty: false
        },
        yAxis: {
             gridLineColor:"black",
             title: {
                text: null
            },
            labels: {
               
                formatter: function () {

                     if(this.value==(value * 4 - value * 8).toFixed(2)){
                        return "";
                    }
                    else if(this.value==(value * 3 - value * 6).toFixed(2)){
                        return "-3SD";
                    }
                     else if(this.value==(value * 2 - value * 4).toFixed(2)){
                        return "-2SD";
                    }
                     else if(this.value==(value - value * 2).toFixed(2)){
                        return "-1SD";
                    }
                     else if(this.value/value==0){
                        return "X";
                    }
                    else if(this.value==value){
                        return "1SD";
                    }
                    else if(this.value==(value * 2).toFixed(2)){
                        return "2SD";
                    }
                    else if(this.value==(value * 3).toFixed(2)){
                        return "3SD";
                    }
                    else if(this.value==(value * 4).toFixed(2)){
                        return "";
                    }
                    return this.value;
//                    }

                }
            },
            tickPositioner: function () {
                var y = [];
                 y.push((value * 4 - value * 8).toFixed(2));
                y.push((value * 3 - value * 6).toFixed(2));
                y.push((value * 2 - value * 4).toFixed(2));
                y.push((value - value * 2).toFixed(2));
                y.push(0);
                y.push(value);
                y.push((value * 2).toFixed(2));
                y.push((value * 3).toFixed(2));
                y.push((value * 4).toFixed(2));
                console.log(y);
                return y;

            },

            min: 0,
            max: 8,

            lineColor: 'black',
            lineWidth: 1
        },
        tooltip:{
              formatter: function () {
                  console.log(this)
            return '<label>' + this.x +
                '日</label><br><span style="color:red">' + this.point.desc_ + '</span>';
        }
        }
        ,
        legend:{
           enabled: false 
        },

        series: [{
                lineWidth: 1,
//                color: 'black',

                data: data
            }

        ],
        navigation: {
            menuItemStyle: {
                fontSize: '10px'
            }
        }
    }
}
